<?php
/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
?>


<?php if( $this->paginator->getTotalItemCount() > 0 ): ?>

  <?php if ($this->display_style == 'wide'): ?>
      <ul class='badges_awards_browse'>
        <?php foreach ($this->paginator as $award): ?>
          <?php 
            $badge = $award->getBadge(); 
            $user = $award->getUser();
            $user_total_awards = Engine_Api::_()->badge()->countUserActiveAwards($user);
          ?>
        <li>
          <?php if ($this->showphoto): ?>
            <div class='badge_award_user_photo'>
              <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon'));?>
            </div>
          <?php endif; ?>
          <div class='badge_award_user_info'>
            <div class='badge_award_user_info_title'>
              <?php echo $user->__toString(); ?>
            </div>
            <div class='badge_award_user_info_meta'>
              <?php echo $this->htmlLink(array('route'=>'badge_award_user','user_id'=>$award->user_id),
                $this->translate(array('%s award','%s awards',$user_total_awards), $user_total_awards)
              )?>
            </div>
          </div>
          <?php if ($this->showphoto): ?>
            <div class='badge_award_badge_photo'>
              <?php echo $this->htmlLink($badge->getHref(), $this->itemPhoto($badge, 'thumb.icon'));?>
            </div>
          <?php endif; ?>
          <div class='badge_award_info'>
            <div class='badge_award_title'>
              <?php echo $award->__toString(); ?>
            </div>
            <?php if ($this->showbadge): ?>
              <div class='badge_award_details'>
                <?php echo $this->translate('%1$s badge', $badge->__toString()); ?>
              </div>
            <?php endif; ?>
            <?php if ($this->showdetails): ?>
              <div class='badge_award_meta'>
                <?php echo $this->timestamp($award->creation_date); ?>
                -
                <?php echo $this->translate(array("%s comment", "%s comments", $award->comment_count), $this->locale()->toNumber($award->comment_count)); ?>
                -
                <?php echo $this->translate(array('%1$s like', '%1$s likes', $award->like_count), $this->locale()->toNumber($award->like_count)); ?>
                   -
                  <?php echo $this->translate(array("%s view", "%s view", $award->view_count), $this->locale()->toNumber($award->view_count)); ?>
                  
              </div>
            <?php endif; ?>

          </div>
        </li>
        <?php endforeach; ?>
      </ul>
    
  <?php else: ?>
    <ul class='badges_awards_quicklist'>
      <?php foreach ($this->paginator as $award): ?>
        <?php 
          $badge = $award->getBadge(); 
          $user = $award->getUser();
        ?>
        <li>
          <?php if ($this->showphoto): ?>
            <div class='badge_award_photo'>
              <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon')); ?>
            </div>
          <?php endif; ?>
          <div class='badge_award_info'>
            <div class='badge_award_title'>
              <?php echo $this->htmlLink($user->getHref(), $this->radcodes()->text()->truncate($user->getTitle(), 18)); ?>
            </div>
            <?php if ($this->showdetails): ?>
              <div class='badge_award_meta'>
                <?php echo $this->htmlLink($award->getHref(), $award->getTitle()); ?>
                <?php echo $this->timestamp($award->creation_date)?>
              </div>
            <?php endif; ?>
            <?php if ($this->showbadge): ?>
              <div class='badge_award_details'>
                <?php echo $this->translate('%1$s badge', $badge->__toString()); ?>
              </div>
            <?php endif; ?>
          </div>
        </li>
      <?php endforeach;?>
    </ul>
  <?php endif; ?>

<?php else: ?>  

  <?php /*
    <div class="tip">
      <span>
        <?php echo $this->translate('There are no awards.');?>
      </span>
    </div>
    */
  ?>
<?php endif; ?>  
